package com.example.friend.controller;

import com.example.common.core.constants.HttpConstants;
import com.example.common.core.controller.BaseController;
import com.example.common.core.model.R;
import com.example.common.core.model.TableDataInfo;
import com.example.friend.aspect.CheckUserStatus;
import com.example.friend.model.exam.dto.ExamDTO;
import com.example.friend.model.exam.dto.ExamQueryDTO;
import com.example.friend.service.IUserExamService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * 功能描述:
 *
 * @author Lenovo
 * @date 2025/4/6
 */
@RestController
@RequestMapping("/user/exam")
public class UserExamController extends BaseController {
    @Resource
    private IUserExamService userExamService;

    @CheckUserStatus
    @PostMapping("/enter")
    public R<Void> enter(@RequestHeader(HttpConstants.AUTHENTICATION) String token,
                         @RequestBody ExamDTO examDTO) {
        return toResult(userExamService.enter(token, examDTO.getExamId()));
    }
    @GetMapping("/list")
    public TableDataInfo list(ExamQueryDTO examQueryDTO) {
        return userExamService.list(examQueryDTO);
    }
}
